﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Homework2
{
    public interface IAccount
    {
        string AccountNumber { get; }
        string Password { get; }
        decimal Balance { get; }
        void Deposit(decimal amount);
        bool Withdraw(decimal amount);
    }
    internal class Account : IAccount
    {

        public string AccountNumber { get; }
        public string Password { get; private set; }
        public decimal Balance { get; protected set; }

        public void ChangePassword(string password)
        {
            Password = password;
        }

        public Account(string accountNumber, string password, decimal initialBalance)
        {
            AccountNumber = accountNumber;
            Password = password;
            Balance = initialBalance;
        }

        public void Deposit(decimal amount)
        {
            Balance += amount;
        }

        public virtual bool Withdraw(decimal amount)
        {
            if (Balance >= amount)
            {
                Balance -= amount;
                return true;
            }
            return false;
        }
        public decimal CheckBalance()
        {
            return Balance;
        }
    }
}
